/**
 * 
 */
package santeclair.connexion.service.technique.echanges.impl;

import org.springframework.stereotype.Service;

import santeclair.connexion.domaine.parametrage.ServicePartenaire;
import santeclair.connexion.domaine.technique.RetourBeanXML;
import santeclair.connexion.facturation.enumeration.CodeRetourEnum;
import santeclair.connexion.facturation.stub.DemanderFacturation;
import santeclair.connexion.facturation.stub.DemanderFacturationResponse;
import santeclair.connexion.facturation.stub.FacturationResponse;
import santeclair.connexion.facturation.stub.Organisme;
import santeclair.connexion.facturation.stub.PriseEnCharge;
import santeclair.connexion.facturation.stub.RecapFacture;
import santeclair.connexion.facturation.stub.Statut;
import santeclair.connexion.service.technique.echanges.exception.ConnexionServiceException;

/**
 * @author hpham
 * 
 */
@Service("connexionSoapServiceMock")
public class ConnexionSoapServiceImplMock extends ConnexionSoapServiceImpl {

    /** {@inheritDoc} */
    @Override
    public RetourBeanXML appelerServiceXML(ServicePartenaire servicePartenaire, RetourBeanXML retourBeanXML) throws ConnexionServiceException {

        if (retourBeanXML.getRequest() instanceof DemanderFacturation) {

            RecapFacture recapFacture = new RecapFacture();
            recapFacture.setNumFacture("11111111");

            Organisme organisme = new Organisme();
            organisme.setIdentifiantNoemie("22222222");
            organisme.setIdentifiantSupplementaire("33333333");

            PriseEnCharge priseEnCharge = new PriseEnCharge();
            priseEnCharge.setNumPEC("P20140925003SIA");
            priseEnCharge.setNumPECAssureur("P20140925003SIA");

            Statut statut = new Statut();
            statut.setCode(CodeRetourEnum.OK.getCode());
            statut.setMessage(null);

            FacturationResponse facturationResponse = new FacturationResponse();
            facturationResponse.setRecapFacture(recapFacture);
            facturationResponse.setOrganisme(organisme);
            facturationResponse.setPriseEnCharge(priseEnCharge);
            facturationResponse.setStatut(statut);

            DemanderFacturationResponse response = new DemanderFacturationResponse();
            response.setFacturationResponse(facturationResponse);

            retourBeanXML.setResponse(response);
            return retourBeanXML;
        } else {
            return super.appelerServiceXML(servicePartenaire, retourBeanXML);
        }
    }
}
